/**
 * 
 */
package wsdl.service;

import java.util.HashMap;

/**
 * @author Maurice & Topia
 * 
 */
public class WSDLBinding {
	private String name;
	private String type;
	private String verb;
	private HashMap<String, WSDLOperation> operations;

	public WSDLBinding(String name, String type) {
		this.name = name;
		this.type = type;

		operations = new HashMap<String, WSDLOperation>();
	}

	public void addOperation(String name, WSDLOperation operation) {
		operations.put(name, operation);
	}

	public String getName() {
		return name;
	}

	public String getType() {
		return type;
	}

	public void setVerb(String verb) {
		this.verb = verb;
	}

	public String getVerb() {
		return verb;
	}

	public WSDLOperation getOperation(String name) {
		WSDLOperation operation = operations.get(name);

		if (operation == null) {
			System.err.println("(WSDLBinding) Unknown operation " + name);
		}

		return operation;
	}

	@Override
	public String toString() {
		String portTypeStr = "binding " + type + " : " + name + "(" + verb + "){\n";

		for (String operation : operations.keySet()) {
			portTypeStr += operations.get(operation).toString() + "\n";
		}

		portTypeStr += "};";

		return portTypeStr;
	}
}
